class Solution(object):
    def movesToMakeZigzag(self, nums):
        ans = 0
        n = len(nums)
        if n == 1:
            return 0
        for i in range(0, n, 2):
            if i == 0:
                ans += max(nums[i] - nums[i + 1] + 1, 0)
            else:
                if i == n - 1:
                    ans += max(nums[i] - nums[i - 1] + 1, 0)
                else:
                    ans += max(nums[i] - min(nums[i - 1], nums[i + 1]) + 1, 0)
        ans2 = 0
        for i in range(1, n, 2):
            if i == n - 1:
                ans2 += max(nums[i] - nums[i - 1] + 1, 0)
            else:
                ans2 += max(nums[i] - min(nums[i - 1], nums[i + 1]) + 1, 0)
        return min(ans, ans2)
